package com.ruoyi.hotel.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.hotel.domain.dto.HlRoomDTO;
import com.ruoyi.hotel.domain.pojo.HlRoomPojo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hotel.domain.HlRoom;
import com.ruoyi.hotel.service.IHlRoomService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房间列表Controller
 * 
 * @author ruoyi
 * @date 2022-12-10
 */
@RestController
@RequestMapping("/hotel/hlroom")
public class HlRoomController extends BaseController
{
    @Autowired
    private IHlRoomService hlRoomService;

    /**
     * 查询房间列表列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlroom:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlRoomPojo hlroomPojo)
    {
        startPage();
        List<HlRoomDTO> list = hlRoomService.selectHlRoomList(hlroomPojo);

        return getDataTable(list);
    }

    /**
     * 导出房间列表列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlroom:export')")
    @Log(title = "房间列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlRoom hlRoom)
    {
//        List<HlRoom> list = hlRoomService.selectHlRoomList(hlRoom);
//        ExcelUtil<HlRoom> util = new ExcelUtil<HlRoom>(HlRoom.class);
//        util.exportExcel(response, list, "房间列表数据");
    }

    /**
     * 获取房间列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlroom:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(hlRoomService.selectHlRoomById(id));
    }

    /**
     * 新增房间列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlroom:add')")
    @Log(title = "房间列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlRoom hlRoom)
    {
        return toAjax(hlRoomService.insertHlRoom(hlRoom));
    }

    /**
     * 修改房间列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlroom:edit')")
    @Log(title = "房间列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlRoom hlRoom)
    {
        return toAjax(hlRoomService.updateHlRoom(hlRoom));
    }

    /**
     * 删除房间列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlroom:remove')")
    @Log(title = "房间列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(hlRoomService.deleteHlRoomByIds(ids));
    }
}
